import {createI18n} from 'vue-i18n'
import useConfigStore from '@/store/useConfigStore'
import {storeToRefs} from 'pinia'

export default function (app) {
  const {language} = storeToRefs(useConfigStore())
  const i18n = createI18n({
    legacy: false,
    locale: language.value,
    fallbackLocale: 'en',
    messages: {
      en: {
        login: {
          title: 'Login',
          btnName: 'submit',
          userLabel: 'Username',
          passwordLabel: 'Password'
        }
      },
      zh: {
        login: {
          title: '登录',
          btnName: '提交',
          userLabel: '用户名',
          passwordLabel: '密码'
        }
      },
      ja: {
        login: {
          title: 'ログイン',
          btnName: '送信',
          userLabel: 'ユーザー名',
          passwordLabel: 'パスワード'
        }
      }
    }
  })
  app.use(i18n)
}
